#include <iostream>
#include <cmath>

using namespace std;
#include <iomanip>
using std::setw;

int main()
{

    double balance1[6] = {1, 2, 3, 4, 5.6, 43.21};
    double balance[] = {};

    balance[1] = 1;

    int n[10];

    for (int i = 0; i < 10; i++)
    {
        n[i] = i + 100;
    }

    cout << "程序使用了 setw() 函数 来格式化输出。" << endl;

    cout << "Element" << setw(13) << "Value" << endl;

    for (int i = 0; i < 10; i++)
    {
        cout << setw(7) << i << setw(13) << n[i] << endl;
    }

    cout << "C++ 多维数组" << endl;
    int a[3][4] = {
        {0, 1, 2, 3},  /*  初始化索引号为 0 的行 */
        {4, 5, 6, 7},  /*  初始化索引号为 1 的行 */
        {8, 9, 10, 11} /*  初始化索引号为 2 的行 */
    };

    cout << "内部嵌套的括号是可选的，下面的初始化与上面是等同的" << endl;

    int b[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            cout << a[i][j] << "\t";
        }
        cout << endl;
    }

    cout << "二维数组的输出: " << endl;
    cout << "请输入数组的长度: ";
    int temp;
    cin >> temp;

    int c[temp][temp];

    for (int i = 0; i < temp; i++)
    {
        for (int j = 0; j < temp; j++)
        {
            cin >> a[i][j];
        }
    }

    cout << "输出" << endl;

    for (int i = 0; i < temp; i++)
    {
        for (int j = 0; j < temp; j++)
        {
            cout << c[i][j] << "\t";
        }
        cout << endl;
    }

    return 0;
}